/**
 * \class EnvContext  EnvContext.h <Generator/context/EnvContext.h>
 *
 *  Created on: 13 apr 2011
 *      \author: Calle
 *
 *  \brief Environment context.
 *
 *  This context is the terminator context for the decorator pattern.
 *  This is where all the identification variables are located which are
 *  scooped over the entire tree.
 *
 *  @see IType
 *  @see Ident
 *
 *  \ingroup Context
 */

#ifndef ENVCONTEXT_H_
#define ENVCONTEXT_H_

#include "IContext.h"

class EnvContext: public IContext {
public:
	/**
	 * \brief Constructor
	 *
	 * Creates a terminated IContext.
	 */
	EnvContext();
	/**
	 * \brief Destructor
	 *
	 *	deletes the type and clears the map.
	 */
	virtual ~EnvContext();

	/**
	 * \brief check if the ident exists in this context
	 *
	 * Checks whether the ident exists in this context.
	 *
	 * @param ident
	 * @return true if exists.
	 */
	virtual bool identExists(const Ident& ident) const;
	/**
	 * \brief add a ident to the environment context.
	 *
	 * Add a ident with a specific type to the environment context.
	 * if the insertion is successful true is return, otherwise false.
	 *
	 *
	 * @param type
	 * @param ident
	 * @return true on success
	 */
	virtual bool addIdent(TypeEnum type,const Ident& ident);

	/**
	 * \brief remove ident from the context
	 *
	 * Remove the ident from the context.
	 * returns true on successful removal.
	 *
	 * @param ident
	 * @return true on success
	 */
	virtual bool removeIdent(const Ident& ident);

	/**
	 * \brief find the type for a ident.
	 *
	 * Finds the type for an ident.
	 * If the ident wasn't found false will be returned.
	 *
	 * @see ExpressionType
	 * @see Ident
	 *
	 * @param[in] ident
	 * @param[in/out] type
	 *
	 * @return True if found
	 */

	virtual bool findType(const Ident& ident,TypeEnum& type)const;



	/**
	 * \brief Implementation of getAllOfType from IContext.
	 *
	 * Checks all occurrences of type in the Context.
	 *
	 * @see IContext
	 *
	 * @param type to be checked
	 * @param list with matching idents.
	 */


	virtual void getAllOfType(TypeEnum type, IContext::TypeList& list) const;


	/**
	 * \brief Implements getParent method, this will return NULL
	 *
	 * This method will return NULL for this context since
	 * it has no parent.
	 *
	 * @return NULL
	 */

	virtual IContext* getParent() const;

private:
  CONTEXT_MAP m_context;

};

#endif /* ENVCONTEXT_H_ */
